package cn.com.qtgl.apis.builtin.comp.service;

import cn.com.qtgl.apis.builtin.comp.proxy.BuiltinProxy;
import cn.com.qtgl.apis.builtin.model.vo.IamUser;
import cn.com.qtgl.apis.builtin.model.vo.user.User;
import cn.melonlib.cores.commons.comp.utils.FilterTools;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.support.ApplicationObjectSupport;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class BuiltinService extends ApplicationObjectSupport {

    @Resource
    private BuiltinProxy builtin;


    @Resource
    private FilterTools filterTools;

//    @Cacheable(cacheNames = {"CurrentUser"},key="#username")
    public User getUser(String openid){
        logger.info("cached current login user...:"+openid);
        return builtin.users(filterTools.createFilters().addEq("openid",openid).getConditionsMap()).getEdges().get(0).getNode();
    }

}
